/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ParametroPeridodoReal.java
 *
 * Created on 05/03/2013, 02:39:35
 */

package com.bs.exibicao;


import com.bs.beans.ParametrosRelatorio;
import java.math.BigDecimal;
import java.util.HashMap;

/**
 *
 * @author Bone
 */
public class ParametroPeridodoReal extends javax.swing.JPanel implements IParametroPeriodo{
    private ParametrosRelatorio parametro;

   

    public ParametroPeridodoReal(String texto) {
        initComponents();
        textoLabel.setText(texto);
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        realFiltro = new com.bs.extensoesSwing.DocumentFilter();
        textoLabel = new javax.swing.JLabel();
        inicioField = new com.bs.extensoesSwing.CampoTexto();
        fimField = new com.bs.extensoesSwing.CampoTexto();

        realFiltro.setRegraDeValidacaoSelecionada(com.bs.extensoesSwing.DocumentFilter.OpcoesDeRegraDeValidacao.REAL);

        textoLabel.setText("Texto:");

        inicioField.setToolTipText("");
        inicioField.setFilter(realFiltro);

        fimField.setToolTipText("");
        fimField.setFilter(realFiltro);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(textoLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(inicioField, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(fimField, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(91, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoLabel)
                    .addComponent(inicioField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(fimField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.bs.extensoesSwing.CampoTexto fimField;
    private com.bs.extensoesSwing.CampoTexto inicioField;
    private com.bs.extensoesSwing.DocumentFilter realFiltro;
    private javax.swing.JLabel textoLabel;
    // End of variables declaration//GEN-END:variables

    @Override
    public Object valorInicial() {
        return new BigDecimal(inicioField.getText());
    }

    @Override
    public Object valorFinal() {
        return new BigDecimal(fimField.getText());
    }

    @Override
    public HashMap<String, Object> parametros() {
        HashMap<String, Object> pars = new HashMap<String, Object>();
        pars.put("INICIO", valorInicial());
        pars.put("FIM", valorFinal());
        return pars;
    }

    @Override
    public ParametrosRelatorio getParametro() {
        return parametro;
    }

    @Override
    public void setParametro(ParametrosRelatorio parametro) {
        this.parametro = parametro;
    }

}
